<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
   <style>
       *{
           margin: 0 auto;
           text-align: center;
       }
   </style>
    <script>
        window.onload = function () {
        };
        var triangle = function () {
            for (var i=1;i<=10;i++){
                for (var j = 1; j <= i; j++) {
                    document.write('*');
                }
                document.write('<br/>');
            }
        };
        var rectangle = function () {
            for (var i=1;i<=4;i++){
                document.write('**********');
                document.write('<br/>');
            }
        };
        var rhombus = function () {
            for (var i=1;i<=10;i++){
                for (var j = 1; j <= i; j++) {
                    document.write('*');
                }
                document.write('<br/>');
            }
            for (var i=9;i>0;i--){
                for (var j = 1; j <= i; j++) {
                    document.write('*');
                }
                document.write('<br/>');
            }
        };
        var draw  = function () {
                var result = prompt('请输入一个你需要的图形[a:三角形;b:矩形;c：菱形;]');
                switch (result) {
                    case 'a':
                        triangle();
                        break;
                    case 'b':
                        rectangle();
                        break;
                    case 'c':
                        rhombus();
                        break;
                    default:
                        draw();
                        break;
                }
        };
        draw()
    </script>
</head>
<body>

</body>
</html>